package com;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import com.mysql.jdbc.Statement;

public class MemberDetail {
	
	Connection connection = null;
	/*String url = "jdbc:mysql://localhost:3306/ramtesting";*/
	
	public MemberDetail() throws ClassNotFoundException, InstantiationException,
								IllegalAccessException, SQLException  {
		System.out.println("111");
		Class.forName("com.mysql.jdbc.Driver").newInstance();
		System.out.println("driver loaded");
		/*connection = DriverManager.getConnection(url,"root","mysql");
		System.out.println("got connection");*/
	}
	
	public ArrayList<String> getMember() throws SQLException {
		 ArrayList<String> memberList = new ArrayList<String>();
		 
		 connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/ramtesting","root","mysql");
		 System.out.println("got connection");
		 
		 /*String query = "select name from employees";
		 System.out.println(query);*/
		 
		 Statement st = (Statement) connection.createStatement();
		 ResultSet rs = st.executeQuery("select name from employees");
		// System.out.println(rs);
		 
		 while(rs.next()) {
			 memberList.add(rs.getString(1));
		 }
		return memberList;
	}

	/*public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, SQLException {
		MemberDetail obj = new MemberDetail();
		System.out.println(obj.getMember());
	}*/
}
